/**
* Created by ren on 2017/1/10.
*/
<template>
  <div class='moreJSJDetail'>
    <div class="item" v-if="data!==''">
      <div>
        <span style="font-size: 16px;color:#333333;">{{data.kinsongoldvo.kinsonName}}</span><img
        src="../../assets/share.png"
        @click="share(data.orderNo)"
        style="float:right;cursor:pointer;">
      </div>
      <div class="pesc">
        <div><label>购买黄金：</label><span>{{(data.buyNumber/1000).toFixed(2)}}g</span></div>
        <div><label>预计收益：</label><span>¥{{(data.expectedEarnings/100).toFixed(2)}}</span></div>
        <div><label>存放日：</label><span>{{data.startTime}}</span></div>
        <div><label>到期日：</label><span>{{data.endTime}}</span></div>
      </div>
    </div>
    <div class="btns">
      <button class="btn" style="margin-right: 140px" @click="xucun" :disabled="data.isRenew!==0||data.isExpire===0">
        续存
      </button>
      <button class="btn" :disabled="data.isRenew!==0||data.isExpire===0" @click="toTqList">提取</button>
    </div>
    <div :class="{ball:true,disabled:!showServerAgreement}"
         style="width: 617px;height: 288px;background: white;z-index: 100;position: fixed;top: 0;margin-top: 15%">
      <div style="text-align: center;font-size: 28px;color:#333333;margin-top: 45px">您确定要续存？</div>
      <div class="btns">

        <button class="btn" style="margin-right: 100px;background: #cccccc" @click="canel">取消</button>
        <button class="btn" @click="confirmXC">确定</button>
      </div>
    </div>
    <div class="overlayer" @touchmove.stop :class="{'show':showServerAgreement}">
    </div>
    <Notify :parentThis='this'></Notify>
  </div>
</template>

<script>
  import API from '../../api'
  import Notify from '../Notify'
  export default {
    name: 'moreJSJDetail',
    components: {
      Notify
    },
    data: function () {
      return {
        notifyStatus: 2,
        showServerAgreement: false,
        data: ''
      }
    },
    methods: {
      canel: function () {
        this.showServerAgreement = false
      },
      xucun: function () {
        this.showServerAgreement = true
      },
      confirmXC: function () {
        this.$cookie.set('more_jsj_xc_obj', JSON.stringify({
          orderNo: this.data.orderNo,
          id: this.data.id
        }))
        this.$router.push({name: 'xcList', params: {jsjId: this.data.kinsongoldvo.id}})
      },
      share: function (orderNo) {
        this.$router.push({name: 'moreShare', params: {orderNo: orderNo}})
      },
      toTqList: function () {
        this.$cookie.set('moreTqData', JSON.stringify({
          style: 'jsj',
          weight: this.data.buyNumber,
          kinsonId: this.$route.params.jsjId,
          orderNo: this.data.orderNo
        }))
        this.$router.push({name: 'tqList'})
      },
      KinsonBuyRecord: function () {
        this.$http.post(API.KinsonBuyRecord, {
          userId: this.$cookie.get('id'),
          nextPage: 0,
          buyId: this.$route.params.jsjId,
          pageSize: 1
        }).then((ret) => {
          const result = ret.body
          if (result.code === 1) {
            this.data = result.object.content[0]
            this.$cookie.set('jsjxc_weight', this.data.buyNumber)
          } else {
            this.notifyStatus = '0|' + result.message
          }
        }, (err) => {
          console.log(err)
        })
      }
    },
    mounted: function () {
      this.KinsonBuyRecord()
    }
  }
</script>
